package com.niconicod.ofb;

import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.niconicod.ofb.actors.PlayerPlane;

public class PlayerPlaneInputProcessor extends InputAdapter {

    private final PlayerPlane playerPlane;

    public PlayerPlaneInputProcessor(PlayerPlane playerPlane) {
        this.playerPlane = playerPlane;
    }

    @Override
    public boolean keyDown(int keycode) {
        System.out.println("Down " + keycode);
        if (keycode == Input.Keys.LEFT){
            playerPlane.getFlightModel().setRudderLevel(1);
        }
        if (keycode == Input.Keys.RIGHT){
            playerPlane.getFlightModel().setRudderLevel(-1);
        }
        if (keycode == Input.Keys.NUM_0){
            playerPlane.getFlightModel().setThrustLevel(0);
        }
        if (keycode == Input.Keys.NUM_1){
            playerPlane.getFlightModel().setThrustLevel(1);
        }
        return true;
    }

    @Override
    public boolean keyUp(int keycode) {
        if (keycode == Input.Keys.LEFT){
            playerPlane.getFlightModel().setRudderLevel(0);
        }
        if (keycode == Input.Keys.RIGHT){
            playerPlane.getFlightModel().setRudderLevel(0);
        }
        return true;
    }
}
